package com.zhongxi.guoyuan.adapter.rewardCoin;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentStatePagerAdapter;
import android.view.ViewGroup;

import com.zhongxi.guoyuan.fragment.hmfragment.DHBestPriceFragment;
import com.zhongxi.guoyuan.fragment.hmfragment.DHNewFragment;
import com.zhongxi.guoyuan.fragment.hmfragment.DHSalesGoodsFragment;
import com.zhongxi.guoyuan.fragment.hmfragment.HMBestPriceFragment;
import com.zhongxi.guoyuan.fragment.hmfragment.HMNewCateFragment;
import com.zhongxi.guoyuan.fragment.hmfragment.HMSalesGoodsFragment;
import com.zhongxi.guoyuan.view.rewardCoin.ItemDoubleFragmentFactory;

/**
 * Created by Administrator on 2017/10/12.
 */

public class DoubleMAdapter extends FragmentStatePagerAdapter {
    private String trim;
    private String id;

    public DoubleMAdapter(FragmentManager fm) {
        super(fm);
    }

    @Override
    public CharSequence getPageTitle(int position) {
        String title="最新";
        switch (position){
            case 0:
                title="最新";
                break;
            case 1:
                title="销量";
                break;
            case 2:
                title="最惠";
                break;
        }
        return title;
    }

    @Override
    public Fragment getItem(int position) {
        return ItemDoubleFragmentFactory.create(position,id,trim);
    }

//    @Override
//    public Object instantiateItem(ViewGroup container, int position) {
//        if (position == 0) {
//            DHNewFragment dhNewFragment = (DHNewFragment) super.instantiateItem(container, position);
//            dhNewFragment.setUpdatePrimary(id, trim);
//            return dhNewFragment;
//        } else if (position == 1) {
//            DHSalesGoodsFragment dhSalesGoodsFragment = (DHSalesGoodsFragment) super.instantiateItem(container, position);
//            dhSalesGoodsFragment.setUpdatePrimary(id, trim);
//            return dhSalesGoodsFragment;
//        } else if (position == 2) {
//            DHBestPriceFragment dhBestPriceFragment = (DHBestPriceFragment) super.instantiateItem(container, position);
//            dhBestPriceFragment.setUpdatePrimary(id, trim);
//            return dhBestPriceFragment;
//        }
//        return super.instantiateItem(container, position);
//    }


    @Override
    public int getItemPosition(Object object) {
        return POSITION_NONE;
    }

    @Override
    public int getCount() {
        return 3;
    }

    public void setItemPrimary(String id, String trim) {
        this.id=id;
        this.trim=trim;
    }
}
